package ${webPackageName}.controller.sys;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import ${commonPackageName}.annotation.Permission;
import ${commonPackageName}.annotation.RequestLog;
import ${servicePackageName}.qo.other.BatchDeleteQo;
import ${servicePackageName}.qo.sys.UserListPageReq;
import ${servicePackageName}.qo.sys.UserReq;
import ${servicePackageName}.service.sys.ISysUserService;
import ${servicePackageName}.vo.sys.UserListPageVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 用户相关接口
 * </p>
 *
 * @author lizihao
 * @since 2020-11-18
 */
<#noparse>
@Api(tags = {"用户相关接口"})
@RestController
@RequestMapping("/base/sysUser")
public class SysUserController {

	@Autowired
	private ISysUserService iSysUserService;
	
	@ApiOperation(value = "新增或修改用户")
	@Permission
	@RequestLog
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
	public Boolean add(@Validated @RequestBody UserReq userReq) throws Exception{
		iSysUserService.saveOrUpdateUser(userReq);
	 return true;
 }
	
	@ApiOperation(value = "删除用户")
	@Permission
	@RequestLog
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
	public Boolean delete(@RequestBody BatchDeleteQo batchDeleteQo) throws Exception{
		iSysUserService.delete(batchDeleteQo);
	 return true;
 }
	
	@ApiOperation(value = "用户信息")
	@Permission
	@RequestLog
    @RequestMapping(value = "/info", method = RequestMethod.POST)
	public UserListPageVo info(@RequestParam("id") Long id) throws Exception{
		UserListPageVo user = iSysUserService.getUserInfo(id);
	 return user;
 }

	@ApiOperation(value = "用户列表")
	@Permission
	@RequestLog
    @RequestMapping(value = "/page", method = RequestMethod.POST)
	public IPage<UserListPageVo> page(@RequestBody UserListPageReq pageReq) throws Exception{
		IPage<UserListPageVo> result = iSysUserService.getUserListPage(pageReq.getPage(), pageReq);
	 return result;
 }
}
</#noparse>